home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / wnos5src.zip / ARP.H < prev    next >
Text File  |  1993-08-09  |  5KB  |  142 lines

  1. /* @(#) $Header: arp.h,v 1.4 90/10/12 19:25:07 deyke Exp $ */
  2.  
  3. #ifndef _ARP_H
  4. #define _ARP_H
  5.  
  6. #ifndef _GLOBAL_H
  7. #include "global.h"
  8. #endif
  9.  
  10. #ifndef _MBUF_H
  11. #include "mbuf.h"
  12. #endif
  13.  
  14. #ifndef _IFACE_H
  15. #include "iface.h"
  16. #endif
  17.  
  18. #ifndef _TIMER_H
  19. #include "timer.h"
  20. #endif
  21.  
  22. /* Lifetime of a valid ARP entry */
  23. #define ARPLIFE        900        /* 15 minutes */
  24.  
  25. /* Lifetime of a pending ARP entry */
  26. #define PENDTIME        45      /* 45 seconds */
  27.  
  28. /* ARP definitions (see RFC 826) */
  29.  
  30. #define ARPLEN          16      /* Size of ARP hdr, minus hardware addresses */
  31.  
  32. /* Address size definitions */
  33. #define IPALEN          4       /* Length in bytes of an IP address */
  34. #define MAXHWALEN       255        /* Maximum length of a hardware address */
  35.  
  36. /* ARP opcodes */
  37. #define ARP_REQUEST     1
  38. #define ARP_REPLY       2
  39. #define RARP_REQUEST    3
  40. #define RARP_REPLY        4
  41.  
  42. /* Hardware types */
  43. #define ARP_NETROM      0       /* Fake for NET/ROM (never actually sent) */
  44. #define ARP_ETHER       1       /* Assigned to 10 megabit Ethernet */
  45. #define ARP_EETHER      2       /* Assigned to experimental Ethernet */
  46. #define ARP_AX25        3       /* Assigned to AX.25 Level 2 */
  47. #define ARP_PRONET      4       /* Assigned to PROnet token ring */
  48. #define ARP_CHAOS       5       /* Assigned to Chaosnet */
  49. #define ARP_IEEE802     6       /* Who uses this? */
  50. #define ARP_ARCNET      7
  51.  
  52. extern char *Arptypes[];        /* Type fields in ASCII, defined in arpcmd */
  53. #define NHWTYPES 8
  54.  
  55. /* Table of hardware types known to ARP */
  56. struct arp_type {
  57.     int16 hwalen;               /* Hardware length */
  58.     int16 iptype;               /* Hardware type field for IP */
  59.     int16 arptype;              /* Hardware type field for ARP */
  60.     int16 pendtime;             /* # secs to wait pending response */
  61.     char *bdcst;                /* Hardware broadcast address */
  62.     char *(*format) __ARGS((char *,char *));
  63.                                 /* Function that formats addresses */
  64.     int (*scan) __ARGS((char *,char *));
  65.                                 /* Reverse of format */
  66. };
  67. extern struct arp_type Arp_type[];
  68. #define NULLATYPE       (struct arp_type *)0
  69.  
  70. /* Format of an ARP request or reply packet. From p. 3 */
  71. struct arp {
  72.     int16 hardware;                /* Hardware type */
  73.     int16 protocol;             /* Protocol type */
  74.     char hwalen;                /* Hardware address length, bytes */
  75.     char pralen;                /* Length of protocol address */
  76.     int16 opcode;               /* ARP opcode (request/reply) */
  77.     char shwaddr[MAXHWALEN];    /* Sender hardware address field */
  78.     int32 sprotaddr;            /* Sender Protocol address field */
  79.     char thwaddr[MAXHWALEN];    /* Target hardware address field */
  80.     int32 tprotaddr;            /* Target protocol address field */
  81. };
  82.  
  83. /* Format of ARP table */
  84. struct arp_tab {
  85.     struct arp_tab *next;       /* Linked list pointers */
  86.     struct timer timer;         /* Time until aging this entry */
  87.     struct mbuf *pending;       /* Queue of datagrams awaiting resolution */
  88.     int32 ip_addr;              /* IP Address, host order */
  89.     int16 hardware;             /* Hardware type */
  90.     int flags;                    /* type of ax25 connection */
  91. #define    DATAGRAM_MODE    0            /* Send datagrams in raw link frames */
  92. #define    CONNECT_MODE    1            /* Send datagrams in connected mode */
  93. #define IPCAM_MODE        2               /* Send datagrams in IPCAM mode */
  94.     char state;                 /* (In)complete */
  95. #define ARP_PENDING     0
  96. #define ARP_VALID       1
  97.     char pub;                   /* Respond to requests for this entry? */
  98.     char *hw_addr;              /* Hardware address */
  99.     int16 hwalen;                /* hardware length used for saving */
  100. };
  101. #define NULLARP (struct arp_tab *)0
  102.  
  103. extern struct arp_tab *Arp_tab;
  104.  
  105. struct arp_stat {
  106.     unsigned recv;              /* Total number of ARP packets received */
  107.     unsigned badtype;           /* Incoming requests for unsupported hardware */
  108.     unsigned badlen;            /* Incoming length field(s) didn't match types */
  109.     unsigned badaddr;           /* Bogus incoming addresses */
  110.     unsigned inreq;             /* Incoming requests for us */
  111.     unsigned replies;           /* Replies sent */
  112.     unsigned outreq;            /* Outoging requests sent */
  113. };
  114. extern struct arp_stat Arp_stat;
  115.  
  116. struct arp_saverecord {
  117.     int32 ip_addr;              /* IP address, host order */
  118.     int16 hardware;             /* Hardware type */
  119.     int    flags;                      /* AX.25 connection type */
  120.     int16 hwalen;               /* Length of hardware address */
  121.     char  pub;                  /* Publish this entry? */
  122. };
  123.  
  124. #define ARP_FILE_VERSION   3             /* incl. ax25 conn. mode */
  125.  
  126. /* In arp.c: */
  127. struct arp_tab *arp_add __ARGS((int32 ipaddr,int16 hardware,char *hw_addr,
  128.         int pub,int flags));
  129. void arp_drop __ARGS((void *p));
  130. int arp_init __ARGS((unsigned int hwtype,int hwalen,int iptype,int arptype,
  131.         int pendtime,char *bdcst,char *(*format) __ARGS((char *,char *)),
  132.         int  (*scan) __ARGS((char *,char *)) ));
  133. void arp_input __ARGS((struct iface *iface,struct mbuf *bp));
  134. struct arp_tab *arp_lookup __ARGS((int16 hardware,int32 ipaddr));
  135. char *res_arp __ARGS((struct iface *iface,int16 hardware,int32 target,struct mbuf *bp));
  136.  
  137. /* In arphdr.c: */
  138. int ntoharp __ARGS((struct arp *arp,struct mbuf **bpp));
  139.  
  140. #endif /* _ARP_H */
  141.  
  142.